<?php namespace Winter\Blog\Updates;

use Schema;
use Winter\Storm\Database\Updates\Migration;
/**
 * CreateTagsTable Migration
 */
class CreateTagsTable extends Migration
{

    /**
     * @inheritDoc
     */
    public function up()
    {
        
        Schema::create('winter_blog_tags', function($table) {
            $table->engine = 'InnoDB';

            $table->increments('id');
            $table->string('slug', 64)->unique();
            $table->string('title', 128)->nullable();
            $table->text('description')->nullable();
            $table->boolean('promote')->default(false);
            $table->string('color', 32)->default('primary');
            $table->timestamps();
        });

        Schema::create('winter_blog_tags_posts', function($table)
        {
            $table->engine = 'InnoDB';
            $table->integer('post_id')->unsigned();
            $table->integer('tag_id')->unsigned();
            $table->primary(['post_id', 'tag_id']);
        });
        
    }

    /**
     * @inheritDoc
     */
    public function down()
    {
        Schema::dropIfExists('winter_blog_tags_posts');
        Schema::dropIfExists('winter_blog_tags');
    }

}
